package cn.zqy.demo.day08;
// String分割， String[] split(String regex)
// 字符串的正则，故按照"."的话，必须转意"\\."

public class Demo06StringSplit {
    public static void main(String[] args) {
        String str1 = "aa,bb,cc,jj,k";
        // split分割字符
        String[] s = str1.split(",");
        for (int i = 0; i < s.length; i++) {
            System.out.print(s[i] + " ");
        }
        System.out.println("==================");

        String str2 = "aa.as.gg.hj.yu.p";
        String[] s2 = str2.split(".");
        System.out.println(s2.length);  // 0 分割失败


        String[] s3 = str2.split("\\.");
        System.out.println(s3.length);  //6  成功
        for (int i = 0; i < s3.length; i++) {
            System.out.print(i+ ". " + s3[i] + " ");
        }
    }
}
